﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/Layouts/Admin.Master" AutoEventWireup="true"
    CodeBehind="StatiticsUserRecommend.aspx.cs" Inherits="MLM.AdminCP.Pages.StatiticsUserRecommend" meta:resourcekey="PageResource1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <asp:Label Text="User ID:" runat="server" ID="lbUserID" 
        meta:resourcekey="lbUserIDResource1"></asp:Label>
    <telerik:RadTextBox runat="server" ID="UserID" 
        meta:resourcekey="UserIDResource2" Width="125px">
    </telerik:RadTextBox>
    <a href="#" id="btnView">
        <asp:Label runat="server" ID="lbView" Text="View" 
        meta:resourcekey="lbViewResource1"></asp:Label>
    </a>
    <div id="divData">
    </div>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">

            String.prototype.format = function () {
                var text = this;
                //decrement to move to the second argument in the array
                var tokenCount = arguments.length;
                //check if there are two arguments in the arguments list
                if (tokenCount < 1) {
                    //if there are not 2 or more arguments there's nothing to replace
                    //just return the original text
                    return text;
                }
                for (var token = 0; token < tokenCount; token++) {
                    //iterate through the tokens and replace their placeholders from the original text in order
                    text = text.replace(new RegExp("\\{" + token + "\\}", "gi"), arguments[token]);
                }
                return text;
            };
            function GetOnlyDate(strDate) {
                strDate = strDate.replace("/Date(", "").replace(")/", "");
                var dt = new Date(parseInt(strDate));
                var date = dt.getDate();
                var mon = dt.getMonth() + 1;
                if (date < 10) date = '0' + date;
                if (mon < 10) mon = '0' + mon;
                return "{0}/{1}/{2}".format(date, mon, dt.getFullYear());
            }
            $(function () {

                $("#btnView").click(function () {
                    var UserID = $find("<%=UserID.ClientID %>").value;
                    $.ajax({
                        type: "POST",
                        url: "/AdminCP/Pages/StatiticsUserRecommend.aspx/GetListDate",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        data: "{'UserID':'" + UserID + "'}",
                        async: true,
                        success: function (msj) {
                            msj.d = JSON.parse(msj.d);

                            if (msj.d.length > 0) {

                                $('#divData').highcharts({
                                    chart: {
                                        type: 'column'
                                    },
                                    title: {
                                        text: 'Statistics New recommended By User'
                                    },
                                    subtitle: {
                                        text: 'Source: amuro.evismedia.com'
                                    },
                                    credits: { enabled: false },
                                    xAxis: {
                                        categories: msj.d[0].User
                                    },
                                    yAxis: {
                                        min: 0,
                                        title: {
                                            text: 'Person'
                                        }
                                    },
                                    tooltip: {
                                        headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                                        pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                    '<td style="padding:0"><b>{point.y:.1f} Person</b></td></tr>',
                                        footerFormat: '</table>',
                                        shared: true,
                                        useHTML: true
                                    },
                                    plotOptions: {
                                        column: {
                                            pointPadding: 0.2,
                                            borderWidth: 0
                                        }
                                    },
                                    series: [{
                                        name: 'New Register',
                                        data: msj.d[0].value

                                    }]
                                });
                            }
                        }
                    });
                });


            });
    

        </script>
    </telerik:RadCodeBlock>
</asp:Content>
